package J11_15;

import java.util.Scanner;

public class Test5 {
    static int[] arr = new int[500001];
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int q = in.nextInt();
        for (int i = 0; i < n; i++) {
            arr[i + 1] = in.nextInt();
        }
        for (int i = 0; i < q ; i++) {
            int tmp = in.nextInt();
            int l = in.nextInt();
            int r = in.nextInt();
            if (tmp == 1) {
                q1(l, r);
            } else {
                System.out.println(q2(l, r, n));
            }
        }

    }
    public static void q1(int x, int y) {
        arr[x] = y;
    }
    public static long q2(int l, int r, int n) {
        long res = 0;
        for (int i = 1; i <= n; i++) {
            res += Math.max(l, Math.min(r, arr[i]));
        }
        return res;
    }
}
